#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e6;
int t,n,m,l,v;
int csq[MAXN];
struct car{
    int wj;
    int cs;
    int js;
    int in()
    {
        cin>>wj>>cs>>js;
    }
}car[MAXN];
int ans1,ans2;
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    cin>>n>>m>>l>>v;
    for(int i=0;i<n;i++)
    {
        car[i].in();
    }
    for(int i=0;i<m;i++)
    {
        cin>>csq[i];
    }
    for(int i=0;i<n;i++)
    {
        if(car[i].cs>0&&car[i].js>0 || car[i].cs>v)
            ans1++;ans2++;
    }
    cout<<ans1<<" "<<ans2<<endl;
    fclose(stdin);
    fclose(stdout);
    return 0;
}
